home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / include / latch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  2.4 KB  |  107 lines

  1. /*
  2.  *   $RCSfile: latch.h,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:45 $      
  5.  */ 
  6. #ifndef __LATCH_H__
  7. #define __LATCH_H__
  8.  
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40. /*
  41.  *    define the type for the short term latches
  42.  */
  43. #define LATCH_MAGIC        0xdf451068
  44.  
  45.  
  46. #define SHARE_LATCH        0x1
  47. #define EXCLUSIVE_LATCH    0x2
  48.  
  49.  
  50. typedef struct {
  51.  
  52.     LIST        waitList;
  53.     short        exclusiveFlag;
  54.     short        shareCount;
  55.     MAGIC        magic;
  56. } LATCH;
  57.  
  58.  
  59.  
  60. #if MAGIC_CHECKING IS_ENABLED
  61.  
  62.  
  63. #define CHECK_LATCH_MAGIC(_latch)                            \
  64.                                                             \
  65.     if (_latch->magic != LATCH_MAGIC)    {                    \
  66.                                                             \
  67.         SM_ERROR(TYPE_FATAL, esmINTERNAL);                    \
  68.     }
  69.  
  70. #define INIT_LATCH_MAGIC(_latch)                            \
  71.                                                             \
  72.     _latch->magic = LATCH_MAGIC;
  73.  
  74.  
  75. #else
  76.  
  77.  
  78. #define CHECK_LATCH_MAGIC(_latch)
  79.  
  80. #define INIT_LATCH_MAGIC(_latch)
  81.  
  82.  
  83. #endif
  84.  
  85.  
  86. /*
  87.  *    define the function prototypes
  88.  */
  89. #ifdef __cplusplus
  90.  
  91.  
  92. extern "C" void        initializeLatch(LATCH *);
  93. extern "C" int        waitLatch(LATCH *, int);
  94. extern "C" void        signalLatch(LATCH *);
  95.  
  96.  
  97. #else
  98.  
  99.  
  100. extern void        initializeLatch(LATCH *);
  101. extern int        waitLatch(LATCH *, int);
  102. extern void        signalLatch(LATCH *);
  103.  
  104.  
  105. #endif
  106. #endif __LATCH_H__
  107.